package com.flyoil.petromp.mvp_p.MessagePresenter;

import android.widget.LinearLayout;

import com.flyoil.petromp.entity.entity_order.MapListEntity;
import com.flyoil.petromp.base.BaseModel;
import com.flyoil.petromp.mvp_m.CourseMessageModel.CourseFinanceMessageModel;
import com.flyoil.petromp.mvp_m.CourseMessageModel.GoodsApproveMessageModel;
import com.flyoil.petromp.mvp_m.CourseMessageModel.GoodsDateExamineMessageModel;
import com.flyoil.petromp.mvp_m.CourseMessageModel.GoodsDemandMessageModel;
import com.flyoil.petromp.mvp_m.CourseMessageModel.GoodsExamineMessageModel;
import com.flyoil.petromp.mvp_m.CourseMessageModel.GoodsOrderMessageModel;
import com.flyoil.petromp.mvp_m.CourseMessageModel.CoursePlanMessageModel;
import com.flyoil.petromp.mvp_m.CourseMessageModel.ServiceApproveMessageModel;
import com.flyoil.petromp.mvp_m.CourseMessageModel.ServiceDemandMessageModel;
import com.flyoil.petromp.mvp_m.CourseMessageModel.ServiceExamineMessageModel;
import com.flyoil.petromp.mvp_m.CourseMessageModel.ServiceOrderMessageModel;
import com.flyoil.petromp.mvp_p.Listener.OrderMessageListener;
import com.flyoil.petromp.mvp_v.ListUIView.BaseUIView;
import com.flyoil.petromp.mvp_v.MessageUIView.OrderMessageUIView;
import com.flyoil.petromp.utils.OrderUtl.OrderListUtil;

import java.util.List;
import java.util.Map;

/**
 * Created by songzhiyin on 2017/10/31.
 * 计划单、物资、服务、财务等单据的详情界面的逻辑处理类
 */

public class OrderMessagePresenter implements OrderMessageListener {
    private OrderMessageUIView uiView;
    private BaseModel model;
    private String type;

    public OrderMessagePresenter(BaseUIView baseUIView, String type) {
        this.uiView = (OrderMessageUIView) baseUIView;
        this.type = type;
        model = new CoursePlanMessageModel();
        initModel();
    }

    @Override
    public void initNetworkData(Map<String, Object> map) {
        model.loadNetworkData(map, this);
    }


    @Override
    public void onsucced(List data) {
        uiView.updataToUI(data);
    }


    @Override
    public void upDataTextsView(List data) {
        uiView.upDataTextsView(data);
    }

    @Override
    public void upDataImgsView(String name, List data) {
        uiView.upDataImgsView(name, data);
    }

    @Override
    public void upDataGoodsView(List data) {
        uiView.upDataGoodsView(data);
    }

    @Override
    public void upDataServiceView(List data) {

    }


    @Override
    public void upDataSiganturesView(List data) {
        uiView.upDataSiganturesView(data);
    }

    @Override
    public void upDataRemarkView(MapListEntity entity) {
        uiView.upDataRemarkView(entity);
    }

    @Override
    public void upDataShowSigantureView(boolean show) {
        uiView.upDataShowSigantureView(show);
    }

    @Override
    public void upDataTitleName(int imgRese, String name) {
        uiView.upDataTitleName(imgRese, name);
    }


    @Override
    public void upDataMoneyView(MapListEntity entity) {
        uiView.upDataMoneyView(entity);
    }



    @Override
    public void upDataShowRemoveImagView(boolean show) {
        uiView.upDataShowRemoveImagView(show);
    }

    @Override
    public void upDataOrderConfirmId(int id) {
        uiView.upDataOrderConfirmId(id);
    }

    @Override
    public void upDataShowBackoutView(boolean showck) {
        uiView.upDataShowBackoutView(showck);
    }

    /**
     * 初始化model
     */
    private void initModel() {

        switch (type) {
            case OrderListUtil.PLAN:
                model = new CoursePlanMessageModel();
                break;
            case OrderListUtil.GOODS_DEMAND:
                model = new GoodsDemandMessageModel();
                break;
            case OrderListUtil.GOODS_APPROVE:
                model = new GoodsApproveMessageModel();
                break;
            case OrderListUtil.GOODS_ORDER:
                model = new GoodsOrderMessageModel();
                break;
            case OrderListUtil.GOODS_EXAMINE:
                model = new GoodsExamineMessageModel();
                break;
            case OrderListUtil.GOODS_DATE_EXAMINE:
                model = new GoodsDateExamineMessageModel();
                break;
            case OrderListUtil.SERVICE_DEMAND:
                model = new ServiceDemandMessageModel();
                break;
            case OrderListUtil.SERVICE_APPROVE:
                model = new ServiceApproveMessageModel();
                break;
            case OrderListUtil.SERVICE_ORDER:
                model = new ServiceOrderMessageModel();
                break;
            case OrderListUtil.SERVICE_EXAMINE:
                model = new ServiceExamineMessageModel();
                break;
            case OrderListUtil.FINANCE:
                model = new CourseFinanceMessageModel();
                break;
        }
    }
}
